import express, { urlencoded,json } from 'express';
import cors from 'cors';

//环境变量加载文件
import  'dotenv/config'
import socket from './scoket/index.js'

import profileRouter from './router/profile.js';
import noteRouter from './router/note.js';
import loginRouter from './router/login.js';
import roleRouter from './router/role.js';
import manageRouter from './router/manage.js'
import commonRouter from './router/common.js'

const app = express()
//导入websocket模块
const http = socket(app)
//中间件
app.use(cors())
app.use(urlencoded({ extended: true,limit:'500mb' }))
app.use(json({ limit: '100mb' }))
app.use(profileRouter)
app.use(noteRouter)
app.use(loginRouter)
app.use(roleRouter)
app.use(manageRouter)
app.use(commonRouter)

http.listen(process.env.PORT,()=>{
    console.log(`项目运行在${process.env.BASEURL}上`)
})